<?php

class User {

    private $username;
    private $password;
    
    // SETTERS

    function setUsername($un) {
        $this->username = $un;
    }

    function setPassword($pw) {
        $this->password = $pw;
    }
    

    //GETTERS

    function getUsername() {
        return $this->username;
    }

    function getPassword() {
        return $this->password;
    }

    
    //ALTRI

    function __construct($un, $pw) {
        $this->setPassword($pw);
        $this->setUsername($un);
        $my_mysqli = new MySQLi();
        $sql = "SELECT * 
            FROM users 
            WHERE username='".$this->getUsername()."' AND password='".$this->getPassword(). "'";
        echo $sql . "\n";
        $result = $my_mysqli->query($sql);
        if (count($result) != 1) {
            $this->__destruct();
        } else {
            return 0;
        }
    }
    
    
    function __destruct() {
        return 1;
    }

}
?>